from django.db import models

class Map(models.Model):
  """Represents a starcraft 2 map. """
  title = models.CharField( max_length=255 )
  image = models.ImageField( upload_to='map_images' )
  size_x = models.IntegerField( )
  size_y = models.IntegerField( )
  karma = models.IntegerField( )

class GameObject( models.Model ):
  RACE_CHOICES = ( (0,'Terran'), (1,'Protoss'), (2,'Zerg') )
    
  name = models.CharField( max_length=55 )
  race = models.IntegerField( choices=RACE_CHOICES )
  icon = models.ImageField( upload_to='object_icons' ) # A path to the icon
  sprite = models.ImageField( upload_to='object_sprites' ) # A path to the game sprite  
  game_model = models.FileField( upload_to='object_models' ) # A path to the 3d model of the game
  size_x = models.FloatField( )
  size_y = models.FloatField( )
  description = models.TextField()
  
  # Some site specific meta information
  actual = models.BooleanField( default=1 ) # Represents actual units - that are in the game
  karma_min = models.IntegerField( ) # Minimum required karma for the user to get the rank of this unit
  karma_max = models.IntegerField( ) # Minimum karma for the rank of this unit

  hitpoints = models.IntegerField( )
  energy = models.IntegerField( )
  armor = models.IntegerField( )
  cost_minerals = models.IntegerField( )
  cost_gas = models.IntegerField( )
  cost_supply = models.IntegerField( )
  build_time = models.IntegerField( ) # In seconds
  
  class Meta:
    abstract = True

class Building( GameObject ):
  pass

class Unit( GameObject ):
  speed = models.IntegerField()
  a1_damage = models.IntegerField()
  a2_damage = models.IntegerField()
  a1_range = models.IntegerField()
  a2_range = models.IntegerField()
  a1_cooldown = models.IntegerField()
  a2_cooldown = models.IntegerField()
  a1_damage_bonus = models.IntegerField() # Bonus damage per each upgrade on attack 1
  a2_damage_bonus = models.IntegerField() # Bonus damage per each upgrade on attack 2
  armor_bonus = models.IntegerField() # Bonus armor per each upgrade
  flyer = models.BooleanField()
  pass
  
  